
using UnityEngine;
using UnityEngine.UI;

public class XiaoGuShi : BaseUI
{
    public Text desc;
    public Transform bgContent;
    public Button closeBtn;

    private string _bgName;
    private string _desc;
    
    protected override void OnInit(params object[] args)
    {
        closeBtn.onClick.AddListener(OnCloseBtnClicked);
    }

    protected override void OnDispose()
    {
        
    }

    protected override void OnOpen(params object[] args)
    {
        _bgName = (string) args[0];
        _desc = (string) args[1];
        
        UpdateShow();
    }

    protected override void OnClose()
    {
        
    }

    public void UpdateShow()
    {
        //更新背景
        CloseAllBg();
        bgContent.Find(_bgName).gameObject.SetActive(true);
        
        //更新故事
        desc.text = _desc;

    }

    public void CloseAllBg()
    {
        for (int i = 0; i < bgContent.childCount; i++)
        {
            bgContent.GetChild(i).gameObject.SetActive(false);
        }
    }

    public void OnCloseBtnClicked()
    {
        Close();
    }
}
